/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package estudando.pojos;

import java.util.Arrays;

/**
 *
 * @author Jurema
 */
public class Vetor {
    
    private Aluno[] alunos = new Aluno[100];
    private int totalAlunos = 0;
    
    public void adiciona(Aluno aluno){
        this.alunos[totalAlunos] = aluno;
        totalAlunos++;
    }
    
    public void adiciona(int posicao, Aluno aluno){
        
    }
    
    public Aluno pega(int posicao){
        
        return null;
    }
    
    public void remove(int posicao){
        
    }
    
    public boolean contem(Aluno aluno){
        
        boolean retorno = false;
        
        for (int i = 0; i < totalAlunos; i++) {
            if(aluno.equals(this.alunos[i])){
                retorno = true;
            }
        }
        
        return retorno;
    }   
    
    public int tamanho(){
        return this.totalAlunos;
    }
    
    public String toString(){
        if(this.totalAlunos == 0){
            return "[]";
        }
        
        StringBuilder builder = new StringBuilder();
        
        builder.append("[");// Abre
        
        for (int i = 0; i < this.totalAlunos - 1; i++) {
            builder.append(this.alunos[i]);
            builder.append(", ");
        }
        
        builder.append(this.alunos[this.totalAlunos-1]);
        
        builder.append("]");// Fecha
        
        return builder.toString();
    }
    
}
